<!DOCTYPE html>
<html>
<head>
    <title>隐私API监控平台</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
</head>
<body>
    <div class="container mt-3">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>隐私API监控平台</h2>
            <div>
                <a href="/config/" class="btn btn-primary me-2">
                    <i class="bi bi-gear"></i> API配置管理
                </a>
                <button class="btn btn-success" onclick="exportLogs()">
                    <i class="bi bi-file-earmark-excel"></i> 导出日志
                </button>
            </div>
        </div>

        <div class="card mb-4">
            <div class="card-header">
                <h5 class="mb-0">筛选条件</h5>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">应用包名</label>
                            <input type="text" class="form-control" id="packageFilter">
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">API类型</label>
                            <select class="form-select" id="tagFilter">
                                <option value="">全部</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">方法名</label>
                            <input type="text" class="form-control" id="methodFilter">
                        </div>
                    </div>
                </div>
                <div class="text-end">
                    <button class="btn btn-primary" onclick="filterLogs()">查询</button>
                </div>
            </div>
        </div>

        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">监控日志</h5>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-hover" id="logsTable">
                        <thead>
                            <tr>
                                <th>时间</th>
                                <th>应用包名</th>
                                <th>API类型</th>
                                <th>方法名</th>
                                <th>设备信息</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="logsBody">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- 调用栈详情模态框 -->
    <div class="modal fade" id="stackTraceModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">调用栈详情</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <pre id="stackTraceContent" style="white-space: pre-wrap;"></pre>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/xlsx@0.17.0/dist/xlsx.full.min.js"></script>
    <script src="js/app.js"></script>
</body>
</html>
